home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-28 | 751 b | 17 lines | [TEXT/R*ch] |
- Newsgroups: comp.sys.mac.programmer
- From: Bruce@hoult.actrix.gen.nz (Bruce Hoult)
- Date: Sun, 7 Aug 1994 16:39:13 +1200 (NZST)
-
- My own sort routine (which I wrote for the Mac in 1987 and haven't
- modified since, btw) chooses the pivot value as the median of the
- first, middle and last elements in the partition. It also minimises
- use of stack space by sorting the smaller of the two new partitions
- recursively (which guarantees no more than log2(n) recursion levels
- and usually more like log3(n)), then iterating to sort the larger one.
- It also switches to a selection sort once the number of elements in
- a partition is small.
-
- I think I've got some good engineering decisions in there :-)
-
- I include it below and hereby place it in the public domain.
-